<template>
  <div class="consult_page">
    <navigate :isVisibleBack="false">咨询预约</navigate>
    <div class="consult_cont">
      <!-- 咨询数  -->
      <div class="num_box">
        <div class="num_info dis_flex justify_center">
          <img src="@/assets/images/consult/1.png" alt="" class="icon_img" />
          <div>当前用户预约/咨询过的次数。</div>
        </div>
        <div class="dis_flex justify_center">
          <div class="cumulative_info">
            <div>累计咨询次数</div>
            <div class="cumulative_num">
              <span>{{ frequency.online_num }}</span
              >次
            </div>
          </div>
          <div class="line"></div>
          <div class="cumulative_info">
            <div>累计预约次数</div>
            <div class="cumulative_num">
              <span>{{ frequency.offline_num }}</span
              >次
            </div>
          </div>
        </div>
      </div>
      <!-- 发起 -->
      <div class="dis_flex just_space">
        <div
          class="initiate_btn white_box dis_flex"
          @click="jumpPage('/initiateConsultation')"
        >
          <img
            src="@/assets/images/consult/initiate01.png"
            alt=""
            class="initiate_img img01"
          />
          <div>
            <div class="initiate_tit">发起咨询</div>
            <div class="initiate_txt">线上对话</div>
          </div>
        </div>
        <div
          class="initiate_btn white_box dis_flex"
          @click="jumpPage('/offlineAppointment')"
        >
          <img
            src="@/assets/images/consult/initiate02.png"
            alt=""
            class="initiate_img img02"
          />
          <div>
            <div class="initiate_tit">发起预约</div>
            <div class="initiate_txt">线下面谈</div>
          </div>
        </div>
      </div>
      <!-- 查看历史记录 -->
      <div>
        <div class="head_label">
          <img src="@/assets/images/common/bar.png" alt="" class="label_img" />
          <div class="label_txt">查看历史记录</div>
        </div>
        <div class="all_record white_box dis_flex">
          <img
            src="@/assets/images/consult/initiate03.png"
            alt=""
            class="initiate_img img03"
          />
          <div
            class="dis_flex just_space flex1"
            @click="jumpPage('/consultationRecord')"
          >
            <div class="">
              <div class="initiate_tit">所有记录</div>
              <div class="initiate_txt">管理所有咨询与预约的记录。</div>
            </div>
            <img
              src="@/assets/images/common/double_right_arrow.png"
              alt=""
              class="right_arrow_img"
            />
          </div>
        </div>
        <!-- 列表 -->
        <div class="record_list white_box">
          <div class="dis_flex">
            <img
              src="@/assets/images/consult/record_icon.png"
              alt=""
              class="record_img"
            />
            <div class="record_txt">
              有{{ unreadList.length }}条未读记录哦。
            </div>
          </div>
          <div class="line_between"></div>
          <div
            class="item_record"
            v-for="(item, index) in unreadList"
            :key="index"
          >
            <div class="circle_box">
              <img
                src="@/assets/images/consult/circle.png"
                alt=""
                class="circle_img"
              />
              <div class="circle_line"></div>
            </div>
            <div class="cont_box flex1">
              <div class="item_time">
                发起时间：{{ convertTimestampToDateTime(item.time) }}
              </div>
              <div class="item_bg">
                <div class="consule_status dis_flex">
                  <img
                    src="@/assets/images/consult/线上咨询.png"
                    alt=""
                    class="status_img"
                    v-if="item.type == 1"
                  />
                  <img
                    src="@/assets/images/consult/线下预约.png"
                    alt=""
                    class="status_img"
                    v-else
                  />
                  <div class="item_user">申请人：{{ item.user_name }}</div>
                </div>
                <div class="dis_flex">
                  <div class="consule_desc item_txt">
                    {{ item.question }}
                  </div>
                  <div class="red_dot"></div>
                </div>
                <div class="consule_expert item_txt">
                  咨询专家：{{ item.consult_name }}
                </div>
                <div class="consule_type item_txt">
                  问题类型：{{ item.question_name }}
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { convertTimestampToDateTime } from "@/utils/time";
import {
  queryUnreadRecords,
  queryCumulativeFrequency,
} from "@/api/consultation/record";
export default {
  data() {
    return {
      unreadList: [],
      frequency: {},
    };
  },
  created() {
    this.getUnreadRecords();
    this.getCumulativeFrequency();
  },
  methods: {
    convertTimestampToDateTime,
    //查询累计次数
    async getCumulativeFrequency() {
      let res = await queryCumulativeFrequency();
      if (res.code == 200) {
        this.frequency = res.data;
      }
    },
    //未读记录
    async getUnreadRecords() {
      let res = await queryUnreadRecords();
      if (res.code == 200) {
        this.unreadList = res.data;
      }
    },
    // 查看历史记录
    jumpPage(path) {
      this.$router.push({ path });
    },
  },
};
</script>

<style lang="less" scoped>
.white_box {
  background: #ffffff;
  border-radius: 6.67px;
}
.dis_flex {
  display: flex;
  align-items: center;
}
.justify_center {
  justify-content: center;
}
.just_space {
  justify-content: space-between;
}
.flex1 {
  flex: 1;
}
.margin_left6 {
  margin-left: 6px;
}
.consult_page {
  background-color: #f4f6fa;
  color: #333333;
}
.consult_cont {
  padding: 10px;
}
.num_box {
  width: 100%;
  height: 120px;
  background-image: url("@/assets/images/consult/bg.png");
  background-size: 100% 120px;
  color: #ffffff;
  font-size: 14px;
  line-height: 14px;
  padding-top: 16.67px;
}
.num_info {
  width: 223.33px;
  height: 28px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid #ffffff;
  border-radius: 14.33px;
  margin: 0 0 16px 10px;
}
.icon_img {
  width: 13.33px;
  height: 13.33px;
  margin-right: 7px;
}
.line {
  width: 1px;
  height: 43.33px;
  margin: 0 40px;
  background: #ffffff;
}
.cumulative_num {
  margin-top: 13.33px;
}
.initiate_btn {
  flex: 1;
  height: 73.33px;
  padding-left: 6.67px;
  margin: 13.33px 6.67px 0 0;
  &:last-child {
    margin-right: 0;
  }
}
.initiate_img {
  width: 43.33px;
  height: 43.33px;
  margin-right: 10px;
  border-radius: 13.89px;
}
.img01 {
  background: #00aeff;
}
.img02 {
  background: #ff9500;
}
.img03 {
  background: #29cca6;
}
.initiate_tit {
  font-size: 15.33px;
  line-height: 15.33px;
}
.initiate_txt {
  opacity: 0.5;
  font-size: 12px;
  line-height: 12px;
  margin-top: 9.33px;
}
.head_label {
  display: flex;
  align-items: center;
  margin: 19px 0;
}
.label_img {
  width: 5.33px;
  height: 15.33px;
  margin-right: 11.33px;
}
.label_txt {
  font-weight: bold;
  font-size: 14.67px;
  line-height: 14.67px;
}
.right_arrow_img {
  width: 13.67px;
  height: 13px;
}
.all_record {
  height: 66.67px;
  padding: 0 13px 0 6.67px;
}
.record_list {
  margin-top: 10px;
  padding: 11.67px 10px 0 10px;
}
.record_img {
  width: 23.33px;
  height: 23.33px;
  margin-right: 10px;
}
.record_txt {
  line-height: 14px;
  opacity: 0.8;
  font-size: 14px;
  font-weight: bold;
  color: #555555;
}
.line_between {
  border-bottom: 1px solid rgba(85, 85, 85, 0.2);
  margin: 11.67px 0 19.33px;
}
.circle_box {
  position: relative;
  margin-left: 4px;
}
.circle_img {
  width: 10px;
  height: 10px;
}
.circle_line {
  position: absolute;
  left: 50%;
  transform: translate(-50%);
  width: 1px;
  height: 170px;
  border-right: 1px dashed #999999;
}
.item_record {
  display: flex;
  font-size: 12.67px;
  color: #555555;
}
.cont_box {
  margin-left: 16px;
  padding-bottom: 20px;
}
.item_time,
.item_user {
  font-size: 14.67px;
  font-weight: bold;
  line-height: 14.67px;
  color: #333333;
}
.item_bg {
  margin-top: 6.67px;
  padding: 23.33px 0 10px 14.33px;
  background: rgba(244, 246, 250, 0.5);
}
.consule_expert {
  margin-top: 30px;
}
.consule_desc {
  margin-top: 16.67px;
}
.red_dot {
  width: 6.67px;
  height: 6.67px;
  background: #ff4e2b;
  border-radius: 50%;
}
.status_img {
  width: 50px;
  height: 16.67px;
  margin-right: 11.33px;
}
.item_txt {
  color: #555555;
  font-size: 12.67px;
  line-height: 12.67px;
}
.consule_type {
  margin-top: 13.13px;
}
</style>
